<template>
	<jk-dialog
		v-model="showDialog"
		title="翻改记录-详情"
		width="1000px"
		:show-content-loading="showLoading"
		append-to-body
		:show-cancel-btn="false"
		:show-confirm-btn="false"
		:show-close-btn="true"
		@on-close="onVisibleChange(false)"
		@on-visible-change="onVisibleChange"
	>
		<el-form ref="ruleForm" label-width="110px">
			<el-row ref="box1">
				<el-col :span="8">
					<el-form-item class="margin-bottom-10" label="日期">
						<span class="read-only-2">{{ ruleForm.belongDate }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item class="margin-bottom-10" label="区域">
						<span class="read-only-2">{{ ruleForm.workshopName }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item class="margin-bottom-10" label="工序">
						<span class="read-only-2">{{ ruleForm.processName }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item class="margin-bottom-10" label="备注">
						<span class="read-only-2">{{ ruleForm.remark }}</span>
					</el-form-item>
				</el-col>
			</el-row>
			<div>
				<div ref="box2" class="flex-between-center margin-bottom-4">
					<div></div>
					<div class="flex-end-center">
						<div class="item-gap"><el-button size="mini">机台数：{{ ruleForm.machineChangeList.length }}</el-button></div>
					</div>
				</div>
				<jk-table ref="xTable" border :data="ruleForm.machineChangeList" :height="dialogTableHeight - 10">
					<vxe-column title="机台" align="left" field="machineName" :width="90" />
					<vxe-column title="客户" align="left" field="customerName" :min-width="120" />
					<vxe-column title="品种" align="left" field="productName" :min-width="120" />
					<vxe-column title="批号" align="left" field="batchCode" :min-width="140"></vxe-column>
					<vxe-column title="改前品种" align="left" field="preProductName" :min-width="120"></vxe-column>
					<vxe-column title="改前批号" align="left" field="preBatchCode" :min-width="140" />
				</jk-table>
			</div>
		</el-form>
	</jk-dialog>
</template>

<script>
    import calHeight from '/src/mixins/cal-dialog-height';
    import { productionMachineChangeRecordGet } from '../../../api/production/xsDailyRenovateStatistic';

    export default {
        props: {
            dialogState: {
                type: Boolean,
                default: false
            },
            dataId: {
                type: [String, Number],
                default: ''
            }
        },
        mixins: [calHeight],
        data() {
            return {
                showDialog: false,
                showLoading: true,
                ruleForm: {
                    machineChangeList: []
                }
            };
        },
        methods: {
            onVisibleChange(e) {
                this.$emit('on-visible-change', e);
                if (!e) {
                    Object.assign(this.$data, this.$options.data());
                }
            },
            getDetailRequest() {
                this.showLoading = true;
                return productionMachineChangeRecordGet({ id: this.dataId }).then(res => {
                    this.showLoading = false;
                    if (res.data.status === 200) {
                        this.ruleForm = res.data.res;
                    }
                });
            }
        },
        watch: {
            dialogState(newVal) {
                this.showDialog = newVal;
                if (newVal && this.dataId) {
                    this.getDetailRequest();
                }
            }
        }
    };
</script>
